package com.xdap.init.controller;

import com.definesys.mpaas.common.http.Response;
import com.xdap.init.service.InitModelFeildService;
import com.xdap.init.service.InitPackageService;
import com.xdap.init.service.InitServiceService;
import com.xdap.init.service.JudgeModelService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @auth lishushu
 * @2023/4/7 11:26
 * @desc {生成service}
 **/
@RestController
@RequiredArgsConstructor
@RequestMapping(value = "/df/createService")
@Slf4j
public class ServiceBySqlController {

    @Autowired
    private InitServiceService initServiceService;


    /**
    *@auth lishushu
    *@2023/4/19 14:20
    *@desc {生成对应的常用的service方法}
    **/
    @PostMapping("/target")
    public Response target(@RequestParam("filePath") String filePath, @RequestParam("formId") String formId,
                           @RequestParam("packageName") String packageName) throws Exception {
        Response res = new Response();
        try {
            packageName = packageName.toLowerCase();
            String result = initServiceService.init(filePath,formId,packageName);


            res.setData(result);
        } catch (Exception e) {
            log.error("初始化持久层报错:{}", e);
            res.setCode(Response.CODE_ERR);
            res.setMessage(e.getMessage());
        }
        return res;
    }


}
